package com.yc.music.utils;

import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

/**
 * <pre>
 *     @author yangchong
 *     blog  : https://github.com/yangchong211
 *     time  : 2017/10/21
 *     desc  : log工具
 *     revise:
 * </pre>
 *
 * @since 2021-05-10
 */
public final class MusicLogUtils {
    private static final String TAG = "MusicPlayer";
    private static boolean isLog = false;

    /**
     * 设置是否开启日志
     *
     * @param isLog 是否开启日志
     */
    public static void setIsLog(boolean isLog) {
        MusicLogUtils.isLog = isLog;
    }

    public static boolean isIsLog() {
        return isLog;
    }

    /**
     * debug
     *
     * @param message message
     */
    public static void d(String message) {
        if (isLog) {
            HiLog.debug(new HiLogLabel(0, 0, TAG), message);
        }
    }

    /**
     * info
     *
     * @param message message
     */
    public static void i(String message) {
        if (isLog) {
            HiLog.info(new HiLogLabel(0, 0, TAG), message);
        }
    }

    /**
     * error
     *
     * @param msg message
     */
    public static void e(String msg) {
        if (isLog) {
            HiLog.error(new HiLogLabel(0, 0, TAG), msg);
        }
    }

    /**
     * error
     *
     * @param message message
     * @param throwable throwable
     */
    public static void e(String message, Throwable throwable) {
        if (isLog) {
            HiLog.error(new HiLogLabel(0, 0, TAG), message, throwable);
        }
    }
}
